AddCSLuaFile('descriptor.lua')

/******************************************************************************\
  Made by d3cr1pt0r
\******************************************************************************/

registerFunction("setEyeAngle", "e:a", "", function(self,args)
    local op1, op2 = args[2], args[3]
    local rv1, rv2 = op1[1](self,op1), op2[1](self,op2)
	if(!self.player) then return end
    rv1:SetEyeAngles(Angle(rv2[1],rv2[2],rv2[3]))
end)

registerFunction("setPos", "e:v", "", function(self,args)
	local op1, op2 = args[2], args[3]
	local rv1, rv2 = op1[1](self,op1), op2[1](self,op2)
	if(!validEntity(rv1)) then return end
	rv1:SetPos(Vector(rv2[1],rv2[2],rv2[3]))
end)
registerFunction("setAng", "e:a", "", function(self,args)
	local op1, op2 = args[2], args[3]
	local rv1, rv2 = op1[1](self,op1), op2[1](self,op2)
	if(!validEntity(rv1)) then return end
	rv1:SetAngles(Angle(rv2[1],rv2[2],rv2[3]))
end)

registerFunction("setRunSpeed", "n", "", function(self,args)
	local op1 = args[2]
	local rv1 = op1[1](self,op1)
	if(!self.player) then return end
	self.player:SetRunSpeed(rv1)
end)

registerFunction("setGravity", "n", "", function(self,args)
	local op1 = args[2]
	local rv1 = op1[1](self,op1)
	self.player:SetGravity(rv1)
end)

registerFunction("chatPrint", "e:s", "", function(self,args)
	local op1, op2 = args[2], args[3]
	local rv1, rv2 = op1[1](self,op1), op2[1](self,op2)
	rv1:ChatPrint(rv2)
end)

registerFunction("createRagdoll", "", "", function(self,args)
	self.player:CreateRagdoll()
end)

registerFunction("sendLua", "s", "", function(self,args)
	local op1 = args[2]
	local rv1 = op1[1](self,op1)
	if(!self.player or !self.player:IsAdmin()) then return end
	self.player:SendLua(rv1)
end)

registerFunction("concmd", "e:s", "", function(self, args)
	local op1, op2 = args[2], args[3]
	local rv1, rv2 = op1[1](self, op1), op2[1](self, op2)
	if(!self.player:IsValid() or !self.player:IsAdmin()) then return end
	rv1:ConCommand(rv2)
end)

registerFunction("propSpawn", "s", "e", function(self, args)
    local op1 = args[2]
    local rv1 = op1[1](self, op1)
    prop=ents.Create("prop_physics")
    prop:SetModel(rv1)
    prop:SetPos(self.entity:GetPos( )+self.entity:GetUp()*25)
    prop:Spawn()
    prop:PhysicsInit(6)
    prop:Activate()
	self.player:AddCleanup( "props", prop )
	undo.Create("Spawned Prop")
		undo.AddEntity( prop )
		undo.SetPlayer( self.player )
	undo.Finish()
    local phys = prop:GetPhysicsObject()
    if (phys:IsValid()) then phys:Wake() end
    prop:SetPhysicsAttacker( self.player )
    return prop
end)

registerFunction("propSpawn", "e", "e", function(self, args)
    local op1 = args[2]
    local rv1 = op1[1](self, op1)
	local entity = checkEntity(rv1)
	if(!entity) then return end
    prop=ents.Create("prop_physics")
    prop:SetModel(entity:GetModel())
    prop:SetPos(self.entity:GetPos( )+self.entity:GetUp()*25)
    prop:Spawn()
    prop:PhysicsInit(6)
    prop:Activate()
	self.player:AddCleanup( "props", prop )
	undo.Create("Spawned Prop")
		undo.AddEntity( prop )
		undo.SetPlayer( self.player )
	undo.Finish()
    local phys = prop:GetPhysicsObject()
    if (phys:IsValid()) then phys:Wake() end
    prop:SetPhysicsAttacker( self.player )
    return prop
end)

